#include <xenctrl.h>
+#include "xc_private.h"
+
#define PERROR(_m, _a...) \
do { \
int __saved_errno = errno; \
/* sleep for this long (milliseconds) between checking the trace buffers */
#define POLL_SLEEP_MILLIS 100
-
+#define DEFAULT_TBUF_SIZE 20
/***** The code **************************************************************/
typedef struct settings_st {
}
}
+void enable_tracing_or_die(int xc_handle)
+{
+ int enable = 1;
+ int tbsize = DEFAULT_TBUF_SIZE;
+
+ if (xc_tbuf_enable(xc_handle, enable) != 0) {
+ if (xc_tbuf_set_size(xc_handle, tbsize) != 0) {
+ perror("set_size Hypercall failure");
+ exit(1);
+ }
+ printf("Set default trace buffer allocation (%d pages)\n", tbsize);
+ if (xc_tbuf_enable(xc_handle, enable) != 0) {
+ perror("Could not enable trace buffers\n");
+ exit(1);
+ }
+ }
+ else
+ printf("Tracing enabled\n");
+}
+
/**
* get_tbufs - get pointer to and size of the trace buffers
* @mfn: location to store mfn of the trace buffers to
*/
void get_tbufs(unsigned long *mfn, unsigned long *size)
{
- uint32_t size32;
+ int ret;
+ dom0_op_t op; /* dom0 op we'll build */
int xc_handle = xc_interface_open(); /* for accessing control interface */
+ unsigned int tbsize;
- if (xc_tbuf_get_size(xc_handle, &size32) != 0)
- goto fail;
- *size = size32;
+ enable_tracing_or_die(xc_handle);
- if (xc_tbuf_get_mfn(xc_handle, mfn) != 0)
- goto fail;
+ if (xc_tbuf_get_size(xc_handle, &tbsize) != 0) {
+ perror("Failure to get tbuf info from Xen. Guess size is 0?");
+ exit(1);
+ }
+ else
+ printf("Current tbuf size: 0x%x\n", tbsize);
+
+
+ op.cmd = DOM0_TBUFCONTROL;
+ op.interface_version = DOM0_INTERFACE_VERSION;
+ op.u.tbufcontrol.op = DOM0_TBUF_GET_INFO;
+
+ ret = do_dom0_op(xc_handle, &op);
xc_interface_close(xc_handle);
- return;
-fail:
- PERROR("Failure to get trace buffer pointer from Xen");
- exit(EXIT_FAILURE);
+ if ( ret != 0 )
+ {
+ PERROR("Failure to get trace buffer pointer from Xen");
+ exit(EXIT_FAILURE);
+ }
+
+ *mfn = op.u.tbufcontrol.buffer_mfn;
+ *size = op.u.tbufcontrol.size;
}
/**